<template>
  <div>
    <div class="box">
        <div class="a">
            <div class="box2">
                <div class="num">303</div>
                <div class="title">累计会员数</div>
            </div>
        </div>
        <div class="a">
            <div class="box2">
                <div class="num">1</div>
                <div class="title">今日新增会员数</div>
            </div>
        </div>
        <div class="a">
            <div class="box2">
                <div class="num">27</div>
                <div class="title">下单会员数</div>
            </div>
        </div>
        <div class="a">
             <div id="myEcharts" :style="{ width: '100%', height: '90%' ,margin:'15px 15px' }"></div>
        </div>
    </div>
        <el-row>
            <el-col :span="12"><common-echarts class="grid-content bg-purple"></common-echarts></el-col>
            <el-col :span="12"><common-list :tableData="tableData" :tableLabel="tableLabel" class="grid-content bg-purple-light"></common-list></el-col>
        </el-row>
    </div>
</template>

<script>
import {defineComponent, ref,  onMounted ,onUnmounted} from 'vue'
import * as echarts from 'echarts'
import commonEcharts from '@/components/lxj/commonEcharts.vue';
import CommonList from '@/components/lxj/commonList.vue';

export default defineComponent({
  components: { commonEcharts, CommonList },
  
    name:'MemberProfile',
    setup(props, context) {

        //列表组件
        const tableData = ref([
            {
                addr:'北京',
                num:'120'
            },
            {
                addr:'上海',
                num:'200'
            },
            {
                addr:'广州',
                num:'150'
            },
            {
                addr:'深圳',
                num:'80'
            },
            {
                addr:'重庆',
                num:'70'
            },
            {
                addr:'成都',
                num:'120'
            },
            {
                addr:'福建',
                num:'130'
            },
        ])
        const tableLabel=ref([
            {
                prop:'addr',
                label:'地区 '
            },
            {
                prop:'num',
                label:'会员数 '
            },
        ])

         /// 声明定义一下echart
    let echart = echarts;

    onMounted(() => {
      initChart();
    });

    onUnmounted(() => {
      echart.dispose;
    });
	
    // 基础配置一下Echarts
    function initChart() {
      let chart = echart.init(document.getElementById("myEcharts"),);
      // 把配置和数据放这里
      chart.setOption({
        tooltip: {
        trigger: 'item'
    },
    legend: {
        top: '0%',
        left: 'left'
    },
    series: [
        {
            name: '访问来源',
            type: 'pie',
            radius: ['40%', '70%'],
            avoidLabelOverlap: false,
            label: {
                show: false,
                position: 'center'
            },
            emphasis: {
                label: {
                    show: true,
                    fontSize: '12',
                    fontWeight: 'bold',
                }
            },
            labelLine: {
                show: true
            },
            data: [
                {value: 148, name: '下单会员数'},
                {value: 1735, name: '未下单会员数'},
            ],

        }
        
    ],
    
      });
      window.onresize = function() {
        //自适应大小
        chart.resize();
      };
    }

        return{
            initChart ,
            tableData,
            tableLabel
        }
    }
})
</script>
<style scoped>
.a{
    width: 23%;
    height: 150px;
    background: rgb(226, 216, 226);
}
.box{
    display: flex;
    justify-content: space-between;
}
.num{
    color: #4685FD;
    font-size: 30px;
}
.box2{
    margin-top: 40px;
    line-height: 40px;
    padding-left: 20px;
}
.title{
    color: #666666;
    font-size: 16px;
}
.box3{
    display: flex;
    width: 100%;
}
</style>